/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: dings
 * Date: 2024-05-17
 * Time: 14:13
 */
public class Test {

    public static void func(Animal animal) {
        animal.eat();
    }

    public static void main(String[] args) {
        func(new Dog("旺财",3));
        func(new Cat("perper",3));
    }

    public static void main4(String[] args) {
        Animal animal1 = new Dog("旺财",2);
        Animal animal2 = new Cat("perper",3);
       /* Dog dog = (Dog) animal1;
        //确保animal1引用的是Dog类的对象
        if(animal1 instanceof Dog) {
            dog.bark();
        }*/


        //animal2.eat();
        //animal2.mimi();
    }
    public static void main3(String[] args) {
        Dog dog = new Dog("旺财",2);
        func(dog);
    }

    public static Animal func1() {
        return new Dog("旺财",2);
    }
    public static void main2(String[] args) {
        Animal animal = func1();
    }


    public static void main1(String[] args) {
        Animal animal1 = new Dog("旺财",2);
        Animal animal2 = new Cat("perper",3);
    }
}
